document.write('<link rel="stylesheet" href="/statics/plugins/oss/style.css">');
document.write('<script type="text/javascript" src="/statics/plugins/oss/js/plupload.full.min.js"></script>');
document.write('<script type="text/javascript" src="/statics/plugins/oss/ziyun_library.js"></script>');

var htmlCodes = [
    '<div>',
    '    <div id="rrapp" v-cloak>',
    '        <!-- 文件上传 -->',
    '        <div v-show="twbGoodsPushModel.stepOne">',
    '            <el-row>',
    '                <el-card class="box-card">',
    '                    <el-steps :active="1" simple>',
    '                        <el-step title="选择经营范围,选择商品" icon="el-icon-edit"></el-step>',
    '                        <el-step title="填写基本参数及价格" icon="el-icon-upload"></el-step>',
    '                        <el-step title="发布商品" icon="el-icon-picture"></el-step>',
    '                    </el-steps>',
    '                </el-card>',
    '            </el-row>',
    '            <el-row>',
    '                <el-card class="box-card">',
    '                    <div slot="header" class="clearfix">',
    '                        <span  style="font-weight:bold;">选择商品<span style="color:rgb(40, 133, 230)">(<span style="color: red;">*&nbsp;</span>可以先选择门店类型,系统会推荐一批商品,再根据情况添加)</span></span>',
    '                    </div>',
    '                    <div class="text item">',
'                           <div style="background-color: #dcdfe6;">',
    '                        <el-row style="background-color:#f5f7fa;">',
    '                           <div style="width:100%">',
    '                            <el-col :span="3" style="background-color: #dddbdb;margin:15px;text-align:center;">' +
    '                               <h3  style="font-weight:bold;color: #409eff ;cursor:pointer;" @click="firstCategoryClick(storeCategoryAndGoods.firstClickFlag,\'firstClickFlag\', storeCategoryAndGoods.fastStores)">数码图文店:</h3>' +
    '                               <p  style="font-size: 12px;color:#999;margin: 10px">商品:商务印刷,包装品,数码打印,标书打印,个性商品,办公用品等</p>' +
    '                            </el-col>',
    '                            <el-col :span="20">',
    '                                <el-row v-for="fastStore in storeCategoryAndGoods.fastStores">',
    '                                    <form class="form-inline" role="form" v-if="fastStore.goodsList.length > 0">',
    '                                        <div class="form-group" style="width:80px;text-align:center">',
    '                                            <span style="font-size: medium ;color:#606266;cursor:pointer;" @click="categoryClick(fastStore) ">{{fastStore.categoryEntity.categoryName}}</span>',
    '                                        </div>',
    '                                        <div class="form-group">',
    '                                            <el-checkbox-group class="form-group" v-model="fastStore.choiceGoodsId" size="small">',
    '                                                <el-checkbox border style="margin: 8px" v-for="goodsEntity in fastStore.goodsList"',
    '                                                             :label="goodsEntity.goodsId"',
    '                                                             :disabled="goodsEntity.twbPushFlag"',
    '                                                             :key="goodsEntity.goodsId">',
    '                                                    {{goodsEntity.name}}',
    '                                                </el-checkbox>',
    '                                            </el-checkbox-group>',
    '                                        </div>',
    '                                    </form>',
    '                                </el-row>',
    '                            </el-col>',
'                               </div>',
    '                        </el-row>',
    '                        <el-row style="background-color:#f5f7fa;">',
    '                            <el-col :span="3" style="background-color: #dddbdb;margin:15px;text-align:center;">' +
    '                               <h3  style="font-weight:bold;color: #409eff;cursor:pointer; " @click="firstCategoryClick(storeCategoryAndGoods.materialClickFlag,\'materialClickFlag\', storeCategoryAndGoods.materialStores)">广告物料店:</h3>' +
    '                               <p  style="font-size: 12px;color:#999;margin: 10px">商品:展示类,室外写真,室内写真,个性商品,办公用品等</p>' +
    '                            </el-col>',    '                            <el-col :span="20">',
    '                                <el-row v-for="materialStore in storeCategoryAndGoods.materialStores">',
    '                                    <form class="form-inline" role="form" v-if="materialStore.goodsList.length > 0">',
    '                                        <div class="form-group" style="width:80px;text-align:center">',
    '                                            <span style="font-size: medium ;color:#606266;cursor:pointer;" @click="categoryClick(materialStore) ">{{materialStore.categoryEntity.categoryName}}</span>',
    '                                        </div>',
    '                                        <div class="form-group">',
    '                                            <el-checkbox-group class="form-group" v-model="materialStore.choiceGoodsId" size="small">',
    '                                                <el-checkbox border style="margin: 8px" v-for="goodsEntity in materialStore.goodsList"',
    '                                                             :label="goodsEntity.goodsId"',
    '                                                             :disabled="goodsEntity.twbPushFlag"',
    '                                                             :key="goodsEntity.goodsId">',
    '                                                    {{goodsEntity.name}}',
    '                                                </el-checkbox>',
    '                                            </el-checkbox-group>',
    '                                        </div>',
    '                                    </form>',
    '                                </el-row>',
    '                            </el-col>',
    '                        </el-row>',
    '                       </div>',
    '                    </div>',
    '                </el-card>',
    '            </el-row>',
    '            <el-row>',
    '                <el-card class="box-card">',
    '                    <el-row>',
    '                        <el-col :span="20">当前已经选择{{checkedNum}}个商品</el-col>',
    '                        <el-col :span="4"><el-button type="primary" @click="enterIntoStepTwo">下一步,配置价格</el-button></el-col>',
    '                    </el-row>',
    '                </el-card>',
    '            </el-row>',
    '        </div>',
    '        <div v-show="twbGoodsPushModel.stepTwo">',
    '            <el-row v-if="twbGoodsPushModel.stepTwo">',
    '                <el-card class="box-card">',
    '                    <div slot="header" class="clearfix">',
    '                        <span style="font-weight:bold;">编辑商品基本信息<span style="color:rgb(40, 133, 230)">(<span style="color: red;">*&nbsp;</span>每套商品系统自动生成一个价格,请按照您的要求自动修改价格,也可以直接设置利润系数)</span></span>',
    '                    </div>',
    '                    <div class="text item">',
    '                        <el-table border :data="goodsChoiceList"',
    '                                  highlight-current-row',
    '                                  :row-class-name="tableRowClassName"',
    '                                  @row-click="onRowClick"',
    '                                  header-row-class-name="tableHead"',
    '                                  size="mini"',
    '                                  @selection-change="handleSelectionChange">',
    '                            style="width: 100%">',
    '                            <el-table-column type="selection" width="55"></el-table-column>',
    '                            <el-table-column label="序号" type="index" align="center" width="60"></el-table-column>',
    '                            <el-table-column align="center" label="商品名" width="180" :render-header="renderHeader">',
    '                                <template slot-scope="scope">',
    // '                                    <el-tooltip class="item" effect="dark" content="温馨提示:点我编辑价格等参数" placement="top-start">',
    '                                        <el-input size="small" v-model="scope.row.goodsEntity.name" />',
    // '                                    </el-tooltip>',
    '                                </template>',
    '                            </el-table-column>',
    '                            <el-table-column  label="商品描述" >',
    '                                   <template slot-scope="scope">',
    '                                       <el-input size="small" v-model="scope.row.goodsEntity.brief" />',
    '                                   </template>',
    '                            </el-table-column>',
    '                            <el-table-column width="160" label="是否无库存销售">',
    '                                <template slot-scope="scope">',
    '                                    <el-switch',
    '                                            v-model="scope.row.goodsEntity.noStore"',
    '                                            active-color="#13ce66"',
    '                                            inactive-color="#ff4949">',
    '                                    </el-switch>',
    '                                </template>',
    '                            </el-table-column>',
    '                            <el-table-column width="160" align="center" label="上下架状态">',
    '                                <template slot-scope="scope">',
    '                                    <el-select v-model="scope.row.goodsEntity.marketable">',
    '                                        <el-option v-for="item in  e.marketableEnum" :key="item.key" :label="item.value" :value="item.key"></el-option>',
    '                                    </el-select>',
    '                                </template>',
    '                            </el-table-column>',
    '                            <el-table-column width="160" align="center" prop="goodsEntity.createTime" label="创建时间"></el-table-column>',
    '                        </el-table>',
    '                    </div>',
    '                </el-card>',
    '            </el-row>',
    '            <el-row v-if="twbGoodsPushModel.stepTwo">',
    '                <el-card class="box-card">',
    '                    <div slot="header" class="clearfix">',
    '                        <span style="font-weight:bold;">商品基本详情及价格信息<span style="color:rgb(40, 133, 230)">(<span style="color: red;">*&nbsp;</span>如果没有适合的规格选项,请点击该规格后方的自定义选项添加您需要的选项)</span></span>',
    '                    </div>',
    '                    <div class="text item">',
    '                        <el-col :span="2"><h4 style="font-weight:bold">规格属性:</h4></el-col>',
    '                        <el-col :span="18">',
    '                            <el-row v-for="normalAttribute in goodsChoiceList[entityIndex].attributeVo.normalAttributeList">',
    '                                <form class="form-inline" role="form">',
    '                                    <div class="form-group">',
    '                                        <span style="color:rgb(40, 133, 230)">{{normalAttribute.goodsAttributeEntity.attributeName}}</span>',
    '                                    </div>',
    '                                    <div class="form-group" style="margin: 8px">',
    '                                        <el-checkbox-group class="form-group" v-model="normalAttribute.selectOption" size="small">',
    '                                            <el-checkbox :disabled="mark.editOptionMark" border style="margin: 8px" v-for="optionEntity in normalAttribute.goodsOptionEntityList"',
    '                                                         :label="optionEntity.optionId"',
    '                                                         :key="optionEntity.optionId">',
    '                                                {{optionEntity.optionName}}',
    '                                            </el-checkbox>',
    '                                            <el-button class="form-group" style="margin-left:20px;" type="success" @click="optionDialog(normalAttribute.goodsAttributeEntity.attributeId)" size="small" round>自定义选项</el-button>',
    '                                        </el-checkbox-group>',
    '                                    </div>',
    '                                </form>',
    '                            </el-row>',
    '                            <el-row v-for="craftAttribute in goodsChoiceList[entityIndex].attributeVo.craftAttributeList">',
    '                                <form class="form-inline" role="form">',
    '                                    <div class="form-group">',
    '                                        <span style="color:#4690e6">{{craftAttribute.goodsAttributeEntity.attributeName}}</span><span style="color: red;">*&nbsp;</span>',
    '                                    </div>',
    '                                    <div class="form-group" style="margin: 8px">',
    '                                        <el-checkbox-group  v-model="craftAttribute.selectOption" size="small">',
    '                                            <el-checkbox :disabled="mark.editOptionMark" border style="margin: 8px" v-for="optionEntity in craftAttribute.goodsOptionEntityList"',
    '                                                         :label="optionEntity.optionId"',
    '                                                         :key="optionEntity.optionId">',
    '                                                {{optionEntity.optionName}}',
    '                                            </el-checkbox>',
    '                                        </el-checkbox-group>',
    '                                    </div>',
    '                                </form>',
    '                            </el-row>',
    '                        </el-col>',
    '                        <el-col :span="4">',
    '                            <el-button type="primary" size="small" @click="createMatrix(\'selectOption\')">确认</el-button>',
    '                            <el-button type="primary" size="small" @click="editOption">编辑</el-button>',
    '                            <el-button v-if="mark.pushMark" size="small" type="primary" @click="nextGoods" >下一个</el-button>',
    '                        </el-col>',
    '                    </div>',
    '                </el-card>',
    '                <el-card class="box-card">',
    '                    <div>',
    '                        <el-button type="primary" @click="volumeSetPrice" size="small">批量设置利润系数</el-button>',
    '                        <el-button type="primary" @click="samePriceSet" size="small">相同价格设置</el-button>',
    '                        <span v-if="" style="float:right;color:rgb(40, 133, 230)">(<span style="color: red;">*&nbsp;</span>带星号的是工艺,如果您选择了工艺,请去配置工艺价格)<el-button style="margin-left: 10px;" @click="craftPrice" type="primary" size="small">工艺配价</el-button></span>',
    '                    </div>',
    '                </el-card>',
    '            </el-row>',
    '            <el-row v-if="twbGoodsPushModel.stepTwo">',
    '                <template>',
    '                    <el-tabs v-model="activeTab" type="card" >',
    '                        <el-tab-pane label="价格配置" name="price">',
    '                            <el-table :data="goodsChoiceList[entityIndex].itemList" size="mini" border  highlight-current-row="true" header-row-class-name="tableHead"  style="width: 100%">',
    '                                <el-table-column align="center" v-for="(columnName,index) in columnNames" :label="columnName">',
    '                                    <template slot-scope="scope">',
    '                                        <!--<el-input placeholder="请输入库存数量" v-model="scope.row.spec" clearable></el-input>-->',
    '                                        <span>{{scope.row.spec[columnName].optionName}}</span>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="库存">',
    '                                    <template slot-scope="scope">',
    '                                        <el-input placeholder="请输入库存数量" v-model="scope.row.store" clearable></el-input>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="起订量">',
    '                                    <template slot-scope="scope">',
    '                                        <el-input placeholder="请输入起订量" v-model="scope.row.minBuyNum" clearable></el-input>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="重量" :render-header="renderHeader">',
    '                                    <template slot-scope="scope">',
    '                                        <el-input placeholder="请输入重量" v-model="scope.row.weight" clearable></el-input>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="单位">',
    '                                    <template slot-scope="scope">',
    '                                        <!--<el-input placeholder="请输入库存数量" v-model="scope.row.unit" clearable></el-input>-->',
    '                                        <el-select v-model="scope.row.unit">',
    '                                            <el-option v-for="unitLibrary in e.unitLibraryList" v-bind:value="unitLibrary.unitName">{{unitLibrary.unitName}}</el-option>',
    '                                        </el-select>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="销售价格" :render-header="renderHeader">',
    '                                    <template slot-scope="scope">',
    '                                        <el-input placeholder="请输入销售价格" v-model="scope.row.totalPrice" clearable></el-input>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="成本价格" :render-header="renderHeader">',
    '                                    <template slot-scope="scope">',
    '                                        <el-input placeholder="请输入成本价格" v-model="scope.row.cost" clearable></el-input>',
    '                                    </template>',
    '                                </el-table-column>',
    '                                <el-table-column align="center" label="上下架状态" :render-header="renderHeader">',
    '                                    <template slot-scope="scope">',
    '                                        <!--<el-input placeholder="请输入库存数量" v-model="scope.row.marketable" clearable></el-input>-->',
    '                                        <el-select v-model="scope.row.marketable">',
    '                                            <el-option v-for="item in e.marketableEnum" :key="item.key" :label="item.value" :value="item.key"></el-option>',
    '                                        </el-select>',
    '                                    </template>',
    '                                </el-table-column>',
    '                            </el-table>',
    '                        </el-tab-pane>',
    '                        <el-tab-pane label="图片详情" name="image">',
    '                            <el-row>',
    '                                <el-col :span="12"><span style="color: red;">*&nbsp;</span >主图列表<el-button id="upload1" style="margin-left: 100px;" type="primary" size="mini">上传商品主图</el-button></el-col>',
    '                                <el-col :span="12">详情图片<el-button style="margin-left: 100px;" type="primary" id="upload2" size="mini">上传详情图片</el-button></el-col>',
    '                            </el-row>',
    '                            <el-row>',
    '                                <!-- 主图 -->',
    '                                <el-col :span="12">',
    '                                    <el-table :data="goodsChoiceList[entityIndex].imageVo.imageEntityList"style="width: 100%">',
    '                                        <el-table-column label="序号" type="index" width="50"></el-table-column>',
    '                                        <el-table-column label="图片预览" width="180">',
    '                                            <template slot-scope="scope">',
    '                                                <img style="height:100px;" :src="\'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/\'+scope.row.imageUrl"/>',
    '                                            </template>',
    '                                        </el-table-column>',
    '                                        <el-table-column  label="操作">',
    '                                            <template slot-scope="scope">',
    '                                                <a @click="delImage(scope.$index,\'image\')">删除</a>',
    '                                            </template>',
    '                                        </el-table-column>',
    '                                    </el-table>',
    '                                </el-col>',
    '                                <!-- 详情图片 -->',
    '                                <el-col :span="12">',
    '                                    <el-table :data="goodsChoiceList[entityIndex].imageVo.infoEntityList"style="width: 100%">',
    '                                        <el-table-column label="序号" type="index" width="50"></el-table-column>',
    '                                        <el-table-column label="图片预览" width="100">',
    '                                            <template slot-scope="scope">',
    '                                                <img style="height:100px;" :src="\'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/\'+scope.row.imageUrl"/>',
    '                                            </template>',
    '                                        </el-table-column>',
    '                                        <el-table-column  label="操作">',
    '                                            <template slot-scope="scope">',
    '                                                <a @click="delImage(scope.$index,\'info\')">删除</a>',
    '                                            </template>',
    '                                        </el-table-column>',
    '                                    </el-table>',
    '                                </el-col>',
    '                            </el-row>',
    '                        </el-tab-pane>',
    '                        <el-tab-pane label="运费设置" name="freight">',
    '                        <zy-freight-template :freightPropId="goodsChoiceList[entityIndex].goodsEntity.freightId" @zy-freight-template-radio="zyfreightRadio">运费组件</zy-freight-template>',
    '                        </el-tab-pane>',
    '                    </el-tabs>',
    '                </template>',
    '            </el-row>',
    '            <el-row>',
    '                <el-card class="box-card">',
    '                    <!--<el-button type="primary" @click="volumeSetPrice" size="small">保存</el-button>-->',
    '                    <el-button type="primary" @click="pushAllGoods" size="small">全部发布</el-button>',
    '                    <el-button v-if="!mark.pushMark" type="primary" @click="returnGoodsList" size="small">返回商品列表</el-button>',
    '                </el-card>',
    '            </el-row>',
    '        </div>',
    '        <el-dialog width="30%" title="自定义选项" :visible.sync="dialogs.addOptionDialog">',
    '            <el-row style="margin: 10px;">',
    '                <form class="form-inline">',
    '                    <el-col :span="6"><lable >选项名称</lable></el-col>',
    '                    <el-col :span="18" ><el-input v-model="addPrivateOption.optionName" autocomplete="off"></el-input></el-col>',
    '                </form>',
    '            </el-row>',
    '            <el-row style="margin: 10px;">',
    '                <el-col :span="6"><lable >选项值</lable></el-col>',
    '                <el-col :span="18"><el-input v-model="addPrivateOption.optionValue" autocomplete="off"></el-input></el-col>',
    '            </el-row>',
    '            <div slot="footer" class="dialog-footer">',
    '                <el-button type="primary" @click="savePrivateOption">确定</el-button>',
    '                <el-button type="primary" @click="cancelPrivateOption">取消</el-button>',
    '            </div>',
    '        </el-dialog>',
    '        <el-dialog width="30%" title="相同价格设置" :visible.sync="dialogs.samePriceDialog">',
    '            <div v-if="twbGoodsPushModel.stepTwo">',
    '                <el-row  v-for="normalAttribute in goodsChoiceList[entityIndex].attributeVo.normalAttributeList">',
    '                    <form class="form-inline" role="form">',
    '                        <div class="form-group">',
    '                            <span style="color:rgb(40, 133, 230)">{{normalAttribute.goodsAttributeEntity.attributeName}}</span>',
    '                        </div>',
    '                        <div class="form-group" style="margin: 8px">',
    '                            <el-checkbox-group class="form-group" v-model="normalAttribute.sameSelectOption" size="small">',
    '                                <el-checkbox  border style="margin: 8px" v-for="optionEntity in normalAttribute.goodsOptionEntityList"',
    '                                              :label="optionEntity.optionId"',
    '                                              :key="optionEntity.optionId">',
    '                                    {{optionEntity.optionName}}',
    '                                </el-checkbox>',
    '                            </el-checkbox-group>',
    '                        </div>',
    '                    </form>',
    '                </el-row>',
    '            </div>',
    '            <el-row>',
    '                <form class="form-inline" role="form">',
    '                    <div class="form-group" style="margin:10px">',
    '                        <span class="form-group">请输入销售价格:</span>',
    '                        <div  class="form-group">',
    '                            <el-input type="number" size="mini" v-model="priceEntity.samePrice" placeholder="请输入价格"/>',
    '                        </div>',
    '                    </div>',
    '                    <div class="form-group" style="margin:10px">',
    '                        <span class="form-group">请输入成本价格:</span>',
    '                        <div class="form-group">',
    '                             <el-input type="number" size="mini" v-model="priceEntity.sameCostPrice" placeholder="请输入成本价格"/>',
    '                        </div>',
    '                    </div>',
    '                </form>',
    '            </el-row>',
    '            <div slot="footer" class="dialog-footer">',
    '                <el-button type="primary" size="mini" @click="enterSamePriceSet" >确定</el-button>',
    '                <el-button type="primary" size="mini" @click="cancelSamePriceSet" >取消</el-button>',
    '            </div>',
    '        </el-dialog>',
    '    </div>',
    ' <zy-goods-craft-price  ref="zyGoodsCraftPrice" ></zy-goods-craft-price>',
    '    <style>',
    '        .tableHead {',
    '            font-size: large;',
    '            color:black;',
    '        }',
    '        .el-table .warning-row {',
    '            background: oldlace;',
    '        }',
    '        .el-table .success-row {',
    '            background: #f0f9eb;',
    '        }',
    '    </style>',
    '</div>'

].join("");

Vue.component('zy-goods-push', {
    template: htmlCodes,
    data:function() {
        return {
            //发布商品步骤模块展示
            twbGoodsPushModel:{
                //发布步骤一
                stepOne:true,
                //发布步骤二
                stepTwo:false
            },
            //----------------------------------发布步骤一所用到的容器元素
            //存放分类和商品信息的容器
            checkedNum: 0,
            storeCategoryAndGoods:{
                fastStores: [
                    // {choiceGoodsId:[],categoryEntity:{categoryName:'数码店测试分类一'},goodsList:[{name:'快印商品11',goodsId:7775051},{name:'快印商品12',goodsId:7775052},{name:'快印商品13',goodsId:7775053}]},
                    // {choiceGoodsId:[],categoryEntity:{categoryName:'数码店测试分类二'},goodsList:[{name:'快印商品21',goodsId:7775054},{name:'快印商品22',goodsId:7775055},{name:'快印商品23',goodsId:7775056}]},
                    // {choiceGoodsId:[],categoryEntity:{categoryName:'数码店测试分类三'},goodsList:[{name:'快印商品31',goodsId:7775057},{name:'快印商品32',goodsId:7775058},{name:'快印商品33',goodsId:7775059}]}
                ],
                materialStores:[
                    // {choiceGoodsId:[],categoryEntity:{categoryName:'广告物料店测试分类一'},goodsList:[{name:'广告物料商品11',goodsId:7775060},{name:'广告物料商品12',goodsId:7775061},{name:'广告物料商品13',goodsId:7775062}]},
                    // {choiceGoodsId:[],categoryEntity:{categoryName:'广告物料店测试分类二'},goodsList:[{name:'广告物料商品21',goodsId:7775063},{name:'广告物料商品22',goodsId:7775064},{name:'广告物料商品23',goodsId:7775065}]}
                ]
            },
            //用户勾选的商品存放容器
            goodsChoiceList:[],
            //----------------------------------发布步骤二所用到的容器元素
            goodsPushIds:[],//用户最终选择发布的商品存放容器
            entityIndex:0,//核心变量,控制选中展示详细信息的索引
            priceEntity:{//相同价格设置存放容器
                samePrice:null,
                sameCostPrice:null,
            },
            mark:{
                editOptionMark:true,//核心变量,控制复选框是否能选择
                ossMark:false,//加载oss标记
                pushMark:true,//操作是发布还是列表进去-->true是发布,false是编辑
                freightIdMark:null,
            },
            activeTab:'price',//tab标签页首先显示第一页
            columnNames:[],//矩阵规格名
            // spanArr:[],
            // pos:null,
            addPrivateOption:{//自定义选项存放模型
                optionName:null,
                optionValue:null,
            },
            //枚举类
            e:{
                marketableEnum:[
                    {key:'puton',value:'上架'},
                    {key:'pulloff',value:'下架'},
                    {key:'delete',value:'删除'},
                ],
                unitLibraryList:[]
            },
            //dialog弹窗类
            dialogs:{
                //自定义选项dialog
                addOptionDialog:false,
                samePriceDialog:false,
            },
        }
    },
    mounted:function(){
        // this.getTestData();
        //初始化加载数据:单位枚举类
        var self = this;
        $.ajax({
            type:"POST",
            url:baseURL+"goods/goods/getUnitLibrary",
            contentType: "application/json",
            success:function(r){
                if(r.code == 0){
                    self.e.unitLibraryList = r.unitLibraryList;
                }else{
                    alert(r.msg);
                }
            }
        })
        $.ajax({
            type:"POST",
            url:baseURL+"goods/goods/getTwbCateAndGoods",
            contentType: "application/json",
            success:function(r){
                if(r.code == 0){
                    self.storeCategoryAndGoods = r.resultMap;
                    self.storeCategoryAndGoods.firstClickFlag = 0;
                    self.storeCategoryAndGoods.materialClickFlag = 0;
                    // self.storeCategoryAndGoods.fastStores
                    for (var fastStore of self.storeCategoryAndGoods.fastStores) {
                        for (var goodsListElement of fastStore.goodsList) {
                            if (!goodsListElement.twbPushFlag){
                                fastStore.choiceGoodsId.push(goodsListElement.goodsId);
                                fastStore.clickFlag = 0;
                            }
                        }
                    }
                    for (var materialStore of self.storeCategoryAndGoods.materialStores) {
                        for (var goodsListElement of materialStore.goodsList) {
                            if(!goodsListElement.twbPushFlag){
                                materialStore.choiceGoodsId.push(goodsListElement.goodsId);
                                materialStore.clickFlag = 0;
                            }
                        }
                    }
                }else{
                    alert(r.msg);
                }
            }
        })
    },
    watch:{
        activeTab: function (val, oldVal) {
            if(!this.mark.ossMark && val == 'image'){
                this.loadOss();
            }
        },
        'storeCategoryAndGoods':{
            handler(value){
                var check = 0;
                for(var i in value.fastStores){
                    check +=  value.fastStores[i].choiceGoodsId.length;
                }
                for(var i in value.materialStores){
                    check +=  value.materialStores[i].choiceGoodsId.length;
                }
                this.checkedNum = check;
            },
            deep: true,
        }
    },
    methods:{
        //初始化商品信息
        initData: function(goodsId){
            var self = this;
            self.twbGoodsPushModel.stepOne = false;
            self.mark.pushMark = false;
            //掉接口,给spu赋值
            $.ajax({
                type:"POST",
                url:baseURL+"goods/goods/getTwbGoodsInfo/"+goodsId,
                contentType: "application/json",
                success:function(r){
                    if(r.code == 0){
                        //首先重置页面元素
                        self.resetProperty();
                        //不知道这里需不需要深克隆
                        Vue.set(self.goodsChoiceList,0,r.twbGoodsVo);
                        // self.goodsChoiceList[row.index].index = row.index;
                        self.createMatrix('selectOption');
                        self.twbGoodsPushModel.stepOne = false;
                        self.twbGoodsPushModel.stepTwo = true;
                    }else{
                        alert(r.msg);
                    }
                }
            })
        },
        // 二级分类 点击全选/反选
        categoryClick: function (stores) {
            if(stores.clickFlag === 0){ //0取消全选 1全选
                stores.choiceGoodsId = [];
                stores.clickFlag = 1;
            } else if (stores.clickFlag === 1){
                for (var i in stores.goodsList){
                    if (!stores.goodsList[i].twbPushFlag){
                        stores.choiceGoodsId.push(stores.goodsList[i].goodsId);
                    }
                }
                stores.clickFlag = 0;
            }
        },
        // 快印分类 点击全选/反选
        firstCategoryClick: function (clickFlag,clickFlagType, stores) {
            if(clickFlag === 0){ //0取消全选 1全选
                for (var i in stores){
                    stores[i].choiceGoodsId = [];
                }
                this.storeCategoryAndGoods[clickFlagType] = 1;
            } else if (clickFlag === 1){
                for (var i in stores){
                    for (var j in stores[i].goodsList){
                        if (!stores[i].goodsList[j].twbPushFlag){
                            stores[i].choiceGoodsId.push(stores[i].goodsList[j].goodsId);
                        }
                    }
                }
                this.storeCategoryAndGoods[clickFlagType] = 0;
            }
        },
        zyfreightRadio:function(freightId){
            this.goodsChoiceList[this.entityIndex].goodsEntity.freightId = freightId;
        },
        returnGoodsList:function(){
            //事件抛出
            this.$emit('zy-push-goods-click');
        },
        //发布商品第二步:
        enterIntoStepTwo:function(){
            //发送请求获得已选中商品
            var goodsIds = [];
            for(var i = 0;i<this.storeCategoryAndGoods.fastStores.length;i++){
                var fastStore = this.storeCategoryAndGoods.fastStores[i];
                goodsIds = goodsIds.concat(fastStore.choiceGoodsId);
            }
            for(var i = 0;i<this.storeCategoryAndGoods.materialStores.length;i++){
                var materialStore = this.storeCategoryAndGoods.materialStores[i];
                goodsIds = goodsIds.concat(materialStore.choiceGoodsId);
            }
            if(goodsIds.length == 0){
                alert("请至少选择一个商品进行发布");
                return
            }
            var self = this;
            $.ajax({
                type:"POST",
                url:baseURL+"goods/goods/getGoodsByGoodsIds",
                contentType: "application/json",
                data: JSON.stringify(goodsIds),
                success:function(r){
                    if(r.code == 0){
                        self.goodsChoiceList = r.goodsChoiceList;
                        self.twbGoodsPushModel.stepOne = false;
                        self.twbGoodsPushModel.stepTwo = true;
                        self.createMatrix('selectOption');
                    }else{
                        alert(r.msg);
                    }
                }
            })
        },
        getTestData:function (){
            this.goodsChoiceList = [
                {
                    goodsEntity:{
                        name:"测试商品1",brief:"商品描述一",marketable:"puton",
                    },
                    productEntityList:[{productId:123,disabled:false,},{productId:1234,disabled:false},{productId:12345,disabled:false}],
                    itemList:[],
                    attributeVo:{
                        normalAttributeList:[
                            {goodsAttributeEntity:{attributeId:1,attributeName:'商品一测试规格1'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品一测试选项1'},
                                    {optionId:2,optionName:'商品一测试选项2'},
                                    {optionId:3,optionName:'商品一测试选项3'}],selectOption:[1]
                            },
                            {goodsAttributeEntity:{attributeId:2,attributeName:'商品一测试规格2'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品一测试选项1'},
                                    {optionId:2,optionName:'商品一测试选项2'},
                                    {optionId:3,optionName:'商品一测试选项3'}],selectOption:[]
                            }],
                        craftAttributeList:[
                            {goodsAttributeEntity:{attributeId:1,attributeName:'商品一测试工艺1'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品一测试工艺选项1'},
                                    {optionId:2,optionName:'商品一测试工艺选项2'},
                                    {optionId:3,optionName:'商品一测试工艺选项3'}],selectOption:[]
                            },
                            {goodsAttributeEntity:{attributeId:2,attributeName:'商品一测试工艺2'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品一测试工艺选项1'},
                                    {optionId:2,optionName:'商品一测试工艺选项2'},
                                    {optionId:3,optionName:'商品一测试工艺选项3'}],selectOption:[]
                            } ],
                    },
                    imageVo:{
                        imageEntityList:[{imageUrl:'goods/images/2018-03-23/20180323054413613.jpg'},{imageUrl:'goods/images/2018-03-23/20180323054413613.jpg'}],
                        infoEntityList:[{imageUrl:'goods/images/2018-03-23/20180323054413613.jpg'}],
                    },
                },
                {
                    goodsEntity:{
                        name:"测试商品2",brief:"商品描述二",marketable:"pulloff",
                    },
                    productEntityList:[{productId:223,disabled:false},{productId:2234,disabled:false},{productId:22345,disabled:false}],
                    attributeVo:{
                        normalAttributeList:[
                            {goodsAttributeEntity:{attributeId:1,attributeName:'商品二测试规格1'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品二测试选项1'},
                                    {optionId:2,optionName:'商品二测试选项2'},
                                    {optionId:3,optionName:'商品二测试选项3'}],selectOption:[]
                            },
                            {goodsAttributeEntity:{attributeId:2,attributeName:'商品二测试规格2'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品二测试选项1'},
                                    {optionId:2,optionName:'商品二测试选项2'},
                                    {optionId:3,optionName:'商品二测试选项3'}],selectOption:[]
                            }],
                        craftAttributeList:[
                            {goodsAttributeEntity:{attributeId:1,attributeName:'商品二测试工艺1'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品二测试工艺选项1'},
                                    {optionId:2,optionName:'商品二测试工艺选项2'},
                                    {optionId:3,optionName:'商品二测试工艺选项3'}],selectOption:[]
                            }],
                    },
                    imageVo:{
                        imageEntityList:[{imageUrl:'goods/images/2018-03-23/20180323054414124.jpg'},{imageUrl:'goods/images/2018-03-23/20180323054414124.jpg'}],
                        infoEntityList:[{imageUrl:'goods/images/2018-03-23/20180323054414124.jpg'}],
                    },
                },
                {
                    goodsEntity:{
                        name:"测试商品3",brief:"商品描述三",marketable:"delete",
                    },
                    productEntityList:[{productId:323,disabled:false},{productId:3234,disabled:false},{productId:32345,disabled:false}],
                    attributeVo:{
                        normalAttributeList:[
                            {goodsAttributeEntity:{attributeId:1,attributeName:'商品三测试规格1'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品三测试选项1'},
                                    {optionId:2,optionName:'商品三测试选项2'},
                                    {optionId:3,optionName:'商品三测试选项3'}],selectOption:[]
                            },
                            {goodsAttributeEntity:{attributeId:2,attributeName:'商品三测试规格2'},goodsOptionEntityList:[
                                    {optionId:1,optionName:'商品三测试选项1'},
                                    {optionId:2,optionName:'商品三测试选项2'},
                                    {optionId:3,optionName:'商品三测试选项3'}],selectOption:[]
                            }],
                        craftAttributeList:[],
                    },
                    imageVo:{
                        imageEntityList:[{imageUrl:'goods/images/2018-03-23/2018032305441427.png'},{imageUrl:'goods/images/2018-03-23/2018032305441427.png'}],
                        infoEntityList:[{imageUrl:'goods/images/2018-03-23/2018032305441427.png'}],
                    },
                }
            ];
        },
        //把每一行的索引放进row-->配合点击事件获取索引
        tableRowClassName({row,rowIndex}){
            row.index = rowIndex;
            if (rowIndex === this.entityIndex) {
                return 'success-row';
            }
            return '';
        },
        onRowClick(row, event, column) {
            this.entityIndex = row.index;
            if(!row.needLoad){
                console.info("该商品已经加载,不需要重新加载");
                return ;
            }
            var self = this;
            //掉接口,给spu赋值
            $.ajax({
                type:"POST",
                url:baseURL+"goods/goods/getTwbGoodsInfo/"+row.goodsEntity.goodsId,
                contentType: "application/json",
                success:function(r){
                    if(r.code == 0){
                        //首先重置页面元素
                        self.resetProperty();
                        //不知道这里需不需要深克隆
                        Vue.set(self.goodsChoiceList,row.index,r.twbGoodsVo);
                        // self.goodsChoiceList[row.index].index = row.index;
                        self.createMatrix('selectOption');
                    }else{
                        alert(r.msg);
                    }
                }
            })
        },
        //复选框勾选时候调用的方法------>>>最后发布的时候,按这里的spu选择情况为主
        handleSelectionChange(val) {
            this.goodsPushIds = [];
            for(var i = 0;i<val.length;i++){
                this.goodsPushIds.push(val[i].goodsEntity.goodsId);
            }
            console.info(this.goodsPushIds);
        },
        // remindEven:function(){
        //     console.info("温馨提示!")
        // },
        createSpecificationItems:function(optionType){
            //遍历选中商品的规格,组装数据
            var specificationItems = [];
            for(var i = 0;i<this.goodsChoiceList[this.entityIndex].attributeVo.normalAttributeList.length;i++){
                var item = {};
                var normalAttributeList = this.goodsChoiceList[this.entityIndex].attributeVo.normalAttributeList[i];
                var attributeId = normalAttributeList.goodsAttributeEntity.attributeId;
                var attributeName = normalAttributeList.goodsAttributeEntity.attributeName;
                var attribute = {};
                attribute.attributeId = attributeId;
                attribute.attributeName = attributeName;
                item.attribute = attribute;
                //也许会报错
                if(normalAttributeList[optionType].length > 0){
                    var option = [];
                    for(var j = 0;j<normalAttributeList[optionType].length;j++){
                        var optionEntity = {};
                        //定义一个方法,按optionId查找optionName
                        var optionId = normalAttributeList[optionType][j];
                        var optionName = this.findName(optionId,normalAttributeList.goodsOptionEntityList);
                        optionEntity.optionId = optionId;
                        optionEntity.optionName = optionName;
                        option.push(optionEntity);
                    }
                    item.option = option;
                }else{
                    //这部分用别的js校验代替
                }
                specificationItems.push(item);
            }
            return specificationItems;
        },
        //定义一个方法,按optionId查找optionName
        findName:function(optionId,optionEntityList){
            for(var i = 0;i<optionEntityList.length;i++){
                if(optionEntityList[i].optionId == optionId){
                    return optionEntityList[i].optionName;
                }
            }
        },
        //给工艺赋值
        valuaMatrixCraft:function(itemList){
            // itemList[0].cra
            var craftAttributeList = this.goodsChoiceList[this.entityIndex].attributeVo.craftAttributeList;
            if(craftAttributeList != null && craftAttributeList.length > 0){
                for(var i = 0;i<craftAttributeList.length;i++){
                    itemList[0].cra = itemList[0].cra.concat(craftAttributeList[i].selectOption);
                }
            }
        },
        //点击确认生成矩阵
        createMatrix:function(optionType){
            //判断是否有选项未选择
            if(this.checkSelectOption(optionType)){
                return;
            }
            this.columnNames = [];
            //先创建specificationItems
            var specificationItems = this.createSpecificationItems('selectOption');
            var itemList = [{
                sku:null,
                spec: {},//该商品规格选项详情
                cra: [],//工艺--->可能舍弃
                store: '',//库存
                unit: '',//单位
                minBuyNum: '',//起订量
                marketable: 'puton',
                weight: '',//重量
                totalPrice: '',//销售价
                cost: '',//成本价
                defaultProduct: false
            }];
            this.valuaMatrixCraft(itemList);
            var items = specificationItems;
            //item的长度是规格属性的个数
            for (var i = 0; i < items.length; i++) {
                itemList = this.addColumn(itemList, items[i].attribute, items[i].option);
            }
            this.handlerProductList(itemList);
            for(var i = 0;i<specificationItems.length;i++){
                this.columnNames.push(specificationItems[i].attribute.attributeName);
            }
            this.mark.editOptionMark = true;
        },
        addColumn: function (list, columnName, columnValues) {
            var newList = [];
            //list的长度是需要克隆的记录条数
            for (var i = 0; i < list.length; i++) {
                var oldRow = list[i];
                //columnValues是每个规格属性选择值的个数
                for (var j = 0; j < columnValues.length; j++) {
                    var newRow = JSON.parse(JSON.stringify(oldRow));//深克隆
                    newRow.spec[columnName.attributeName] = columnValues[j];
                    newList.push(newRow);
                }
            }
            return newList;
        },
        handlerProductList:function(itemList){
            //遍历itemList,将sku的信息放入这这些矩阵
            for(var i = 0;i<itemList.length;i++){
                var optionIds = [];
                for(option in itemList[i].spec){
                    optionIds.push(itemList[i].spec[option].optionId);
                }
                //定义一个方法,根据optionIds匹配goodsProductEntity
                var goodsProductEntity = this.getGoodsProductEntity(optionIds);
                if(!isBlank(goodsProductEntity)){
                    this.shiftData2Matrix(itemList[i],goodsProductEntity);
                }
            }
            //完成-------------->这里改用set
            this.goodsChoiceList[this.entityIndex].itemList = itemList;
            // this.getSpanArr(this.goodsChoiceList[this.entityIndex].itemList);
            console.info(this.goodsChoiceList[this.entityIndex]);
        },
        //定义一个方法,根据optionIds匹配goodsProductEntity
        getGoodsProductEntity:function(optionIds){
            //暂不考虑会出现2个sku的现象,
            for(var i = 0;i<this.goodsChoiceList[this.entityIndex].productEntityList.length;i++){
                var goodsProduct = this.goodsChoiceList[this.entityIndex].productEntityList[i];
                var ids = goodsProduct.optionIds.split(",");
                if(ids.sort().toString() == optionIds.sort().toString()){
                    return goodsProduct;
                }
            }
            //下列代码仅测试使用
            return null;
        },
        //将sku的信息赋值给矩阵数据
        shiftData2Matrix:function(item,goodsProductEntity){
            item.store = goodsProductEntity.store;//库存
            item.minBuyNum = goodsProductEntity.minBuyNum;//起订量
            item.weight = goodsProductEntity.weight;//重量
            item.unit = goodsProductEntity.unit;//单位
            item.totalPrice = goodsProductEntity.totalPrice;//销售价格
            item.cost = goodsProductEntity.cost;//成本价格
            item.marketable = goodsProductEntity.marketable;//上下架状态
        },
        //下一个商品
        nextGoods:function(){
            if(this.entityIndex + 1 == this.goodsChoiceList.length){
                this.$message('我已经是最后一条商品!');
                return;
            }
            this.entityIndex = this.entityIndex + 1;
            this.onRowClick(this.goodsChoiceList[this.entityIndex]);
        },
        //每次加载商品数据前,将一些数据重置为初始状态
        resetProperty(){
            this.activeTab = 'price';//tab页置为第一页
            this.columnNames = [];
            this.mark.editOptionMark = true;//每次切换都将复选框置为不可选择
        },
        //定义一个方法,校验用户是否有规格没有选项
        checkSelectOption(optionType){
            for(var i = 0;i<this.goodsChoiceList[this.entityIndex].attributeVo.normalAttributeList.length;i++){
                var normalAttribute = this.goodsChoiceList[this.entityIndex].attributeVo.normalAttributeList[i];
                if(normalAttribute[optionType].length == 0){
                    this.$alert('每个规格都必须至少有一个选项!', '温馨提示', {
                        confirmButtonText: '确定',
                        callback:function() {
                            this.$message({
                                type: 'info',
                                message: `请记得添加选项再确认`
                            });
                        }
                    });
                    return true;
                }
            }
        },
        //批量设置利润系数
        volumeSetPrice:function(){
            var self = this;
            this.$prompt('请输入利润系数(系数*成本价 = 销售价格)', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /([1-9][0-9]*(\.\d{1,2})?)|(0\.\d{1,2})/,
                inputErrorMessage: '利润系数需要输入数字类型!'
            }).then(function({ value }){
                for(var i = 0;i<self.goodsChoiceList[self.entityIndex].itemList.length;i++){
                    var item = self.goodsChoiceList[self.entityIndex].itemList[i];
                    item.totalPrice = (item.cost * value).toFixed(2);
                }
                self.$message({
                    type: 'success',
                    message: '价格利润系数' + value + '设置成功'
                });
            }).catch(function(){
                self.$message({
                    type: 'info',
                    message: '取消输入'
                });
            });
        },
        samePriceSet:function(){
            this.dialogs.samePriceDialog = true;
        },
        editOption:function(){
            this.mark.editOptionMark = false;
        },
        //自定义选项弹框
        optionDialog:function(attributeId){
            this.addPrivateOption.attributeId = attributeId;
            this.dialogs.addOptionDialog = true;
        },

        //保存增加选项
        savePrivateOption:function(){
            if(isBlank(this.addPrivateOption.optionName)){
                alert("选项名不能为空");
                return;
            }
            //发送ajax请求生成私有选项
            var self = this;
            $.ajax({
                type: "POST",
                url: baseURL + "goods/goodsattribute/newOption",
                contentType: "application/json",
                data:JSON.stringify(self.addPrivateOption),
                // data:JSON.stringify(attribute),
                success: function (r) {
                    //重新加载规格选项
                    if(r.code == 0){
                        if(r.goodsOptionEntity != null){
                            //返回处理
                            for(var i = 0;i<self.goodsChoiceList[self.entityIndex].attributeVo.normalAttributeList.length;i++){
                                var normalAttribute = self.goodsChoiceList[self.entityIndex].attributeVo.normalAttributeList[i];
                                if(normalAttribute.goodsAttributeEntity.attributeId == r.goodsOptionEntity.attributeId){
                                    normalAttribute.goodsOptionEntityList.push(r.goodsOptionEntity);
                                }
                            }
                        }else{
                            alert("新增选项异常,请联系管理员")
                        }
                    }
                }
            })
            this.dialogs.addOptionDialog = false;
        },
        //取消保存选项
        cancelPrivateOption:function(){
            //重置值
            this.addPrivateOption.attributeId = null;
            this.addPrivateOption.optionName = null;
            this.addPrivateOption.optionValue = null;
            this.dialogs.addOptionDialog = false;
        },
        //工艺价格详情
        craftPrice:function(){
            debugger;
            var attributeIds =[];
            for(var i = 0 ;i<this.goodsChoiceList[this.entityIndex].attributeVo.craftAttributeList.length;i++){
                var attribute = this.goodsChoiceList[this.entityIndex].attributeVo.craftAttributeList[i].goodsAttributeEntity;
                attributeIds.push(attribute.attributeId);
            }
            var templateId =  this.goodsChoiceList[this.entityIndex].goodsCategoryEntity.templateIds
            var data={templateId:templateId,attributeId:attributeIds.join(",")};
            console.info(JSON.stringify(data));
            // window.dialogCraftPricVm.setData(data);
            this.$refs.zyGoodsCraftPrice.setData(data);
        },
        //删除图片
        delImage:function(index,type){
            if(type == 'image'){
                this.goodsChoiceList[this.entityIndex].imageVo.imageEntityList.splice(index,1);
            }else{
                this.goodsChoiceList[this.entityIndex].imageVo.infoEntityList.splice(index,1);
            }

        },
        //相同价格设置确认
        enterSamePriceSet:function(){
            //生成一个新的矩阵
            var optionType = 'sameSelectOption';
            //判断是否有选项未选择
            if(this.checkSelectOption(optionType)){
                return;
            }
            //先创建specificationItems
            var specificationItems = this.createSpecificationItems('sameSelectOption');
            var itemList = [{
                sku:null,
                spec: {},//该商品规格选项详情
                cra: [],//工艺--->可能舍弃
                store: '',//库存
                unit: '',//单位
                minBuyNum: '',//起订量
                marketable: 'puton',
                weight: '',//重量
                totalPrice: '',//销售价
                cost: '',//成本价
                defaultProduct: false
            }];
            var items = specificationItems;
            //item的长度是规格属性的个数
            for (var i = 0; i < items.length; i++) {
                itemList = this.addColumn(itemList, items[i].attribute, items[i].option);
            }
            //遍历商品列表,把规格选项相同的值丢进去
            for(var j = 0; j<itemList.length;j++){
                var item = itemList[j];
                this.setOneSamePrice(item);
            }
            this.cancelSamePriceSet();
        },
        //给每一个item匹配当前sku,将其价格改变
        setOneSamePrice(sourceItem){
            var optionIds = [];
            for(option in sourceItem.spec){
                optionIds.push(sourceItem.spec[option].optionId);
            }
            var item = this.changeSameItem(optionIds)
            if(!isBlank(item)){
                if(!isBlank(this.priceEntity.samePrice)){
                    item.totalPrice = this.priceEntity.samePrice;
                }
                if(!isBlank(this.priceEntity.sameCostPrice)){
                    item.cost = this.priceEntity.sameCostPrice;
                }
            }
        },
        //定义一个方法,匹配item的spec下的optionId
        changeSameItem(sourceOptionIds){
            for(var i = 0;i<this.goodsChoiceList[this.entityIndex].itemList.length;i++){
                var item = this.goodsChoiceList[this.entityIndex].itemList[i]
                var optionIds = [];
                for(option in item.spec){
                    optionIds.push(item.spec[option].optionId);
                }
                if(sourceOptionIds.sort().toString() == optionIds.sort().toString()){
                    return item;
                }
            }
        },
        //取消相同价格设置
        cancelSamePriceSet:function(){
            this.dialogs.samePriceDialog = false;
            for(var i = 0;i<this.goodsChoiceList[this.entityIndex].attributeVo.normalAttributeList.length;i++){
                var normalAttribute = this.goodsChoiceList[this.entityIndex].attributeVo.normalAttributeList[i];
                normalAttribute.sameSelectOption = [];
            }
            this.samePrice = null;
        },
        //发布所有商品
        pushAllGoods:function(){
            var twbGoodsVoPushList = [];
            for(var i = 0;i<this.goodsPushIds.length;i++){
                for(var j = 0;j<this.goodsChoiceList.length;j++){
                    if(this.goodsPushIds[i] == this.goodsChoiceList[j].goodsEntity.goodsId){
                        twbGoodsVoPushList.push(this.goodsChoiceList[j])
                    }
                }
            }
            // 做校验
            if(this.validator(twbGoodsVoPushList)){
                return;
            }
            var self = this;
            $.ajax({
                type: "POST",
                url: baseURL + "goods/goods/twbListPushGoods/"+self.mark.pushMark,
                contentType: "application/json",
                data:JSON.stringify(twbGoodsVoPushList),
                success: function (r) {
                    //重新加载规格选项
                    if(r.code == 0){
                        if(!self.mark.pushMark){
                            self.$emit('zy-push-goods-click');
                            window.parent.vm.zyRouter({
                                url:'modules/twbGoods/twbGoodsList.html',
                                name:'商品列表',
                                blank: true,
                                vmName:'twbGoodsListVue',
                                params:{refresh:true},
                            });
                        }else{
                            //跳转
                            window.parent.vm.zyRouter({
                                url:'modules/twbGoods/twbGoodsList.html',
                                name:'商品列表',
                                blank: true,
                                closeBlank:true,
                                vmName:'twbGoodsListVue',
                                params:{refresh:true},
                            });
                        }
                    }else{
                        alert(r.msg)
                    }
                }
            })
        },
        //发布校验
        validator:function(twbGoodsVoPushList){
            if(!(twbGoodsVoPushList != null && twbGoodsVoPushList.length > 0)){
                alert("尚未勾选需要发布的商品!")
                return true;
            }
            for (var twbGoodsVo of twbGoodsVoPushList) {
                if(isBlank(twbGoodsVo.goodsEntity.name)){
                    alert("准备发布的商品列表含商品名为空的,请修正!")
                }
                if(isBlank(twbGoodsVo.goodsEntity.freightId)){
                    alert("商品"+ twbGoodsVo.goodsEntity.name +"未绑定运费模板")
                }
                if(twbGoodsVo.needLoad){
                    continue;
                }
                //校验每一个item的价格
                for (var item of twbGoodsVo.itemList) {
                    if(isBlank(item.weight)){
                        //重量为空
                        alert("商品名:"+twbGoodsVo.goodsEntity.name+"的重量信息存在空值,请补全")
                        return true;
                    }
                    // if(isBlank(item.unit)){
                    //     //单位为空
                    //     alert("商品名:"+twbGoodsVo.goodsEntity.name+"的单位信息存在空值,请补全")
                    //     return true;
                    // }
                    if(isBlank(item.totalPrice)){
                        //销售价格为空
                        alert("商品名:"+twbGoodsVo.goodsEntity.name+"的销售价格信息存在空值,请补全")
                        return true;
                    }
                    if(isBlank(item.cost)){
                        //成本价为空
                        alert("商品名:"+twbGoodsVo.goodsEntity.name+"的成本价信息存在空值,请补全")
                        return true;
                    }
                    if(isBlank(item.marketable)){
                        //上下架状态为空
                        alert("商品名:"+twbGoodsVo.goodsEntity.name+"的上下架状态信息存在空值,请补全")
                        return true;
                    }
                }
            }
        },
        //列合并方法
        objectSpanMethod({ row, column, rowIndex, columnIndex }) {
            if (columnIndex === 0) {
                if (rowIndex % 2 === 0) {
                    return {
                        rowspan: 2,
                        colspan: 1
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0
                    };
                }
            }
        },
        getSpanArr(data) {
            for (var i = 0; i < data.length; i++) {
                if (i === 0) {
                    this.spanArr.push(1);
                    this.pos = 0
                } else {
                    // 判断当前元素与上一个元素是否相同
                    if (data[i].name === data[i - 1].name) {
                        this.spanArr[this.pos] += 1;
                        this.spanArr.push(0);
                    } else {
                        this.spanArr.push(1);
                        this.pos = i;
                    }
                }
            }
        },
        cellMerge({ row, column, rowIndex, columnIndex }) {
            if (columnIndex === 0) {
                const _row = this.spanArr[rowIndex];
                const _col = _row > 0 ? 1 : 0;
                return {
                    rowspan: _row,
                    colspan: _col
                }
            }
        },
        //oss上传方法
        loadOss:function(){
            var self = this;
            /* oss上传 */
            $.files_up_oss({
                id: ["upload1", "upload2"],//按钮id
                url: "/sys/oss/getSignature",
                dir: "test/pop/twbGoods/goodsImages/",
                file_type: "jpg,png,gif,psd,ai,cdr,eps,ppt,word,excel,pdf,tiff,rar,zip,7z",
                size: "100mb",//mb
                view_url: "https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/"
            }, function (index_number, json) {
                if(json.Status == 'OK'){
                    var goodsImageEntity = {};
                    goodsImageEntity.imageUrl = json.filename;
                    if (index_number == 0) {
                        //商品默认图片
                        goodsImageEntity.type = 0;
                        self.goodsChoiceList[self.entityIndex].imageVo.imageEntityList.push(goodsImageEntity);
                    }else{
                        //详情图片
                        goodsImageEntity.type = 1;
                        self.goodsChoiceList[self.entityIndex].imageVo.infoEntityList.push(goodsImageEntity);
                    }
                }
            });
            this.mark.ossMark = true;
        },
        renderHeader:function(h, { column, $index }){
            return h(
                'span',
                [
                    h('span', {style:'color:red;margin-left:5px;'},'* '),
                    h('span', column.label),
                ],
            );
        }
    }

});